/*****************************************************************************/
/**
*
* @file wm8978.h
*
* Header file for wm8978.c.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver   Who    Date   	Changes
* ----- ---- ---------- -------------------------------------------------------
* 0.01  abu  05/20/2019 Created
* </pre>
*
*------------------------------------------------------------------------------
* Author: abu	E-mail:	abu_liu@aliyun.com
*				Blog:	https://blog.csdn.net/ClamerKorallen
*				Gitee:	https://gitee.com/abu_liu
*------------------------------------------------------------------------------
*
******************************************************************************/

#ifndef WM8978_H
#define WM8978_H

#ifdef __cplusplus
extern "C" {
#endif

/***************************** Include Files *********************************/
#include "uiicps.h"

/************************** Constant Definitions *****************************/
#define WM8978_CPU_IIC_PTR	&uiic0ps	//declare which iic device is being used by wm8978
#define WM8978_BASEADDR	0x76U	//A1/A0 are defined by PL
#define wm8978_MCLKHZ	28000000	//Mclk is derived from PL
#define wm8978_REG_NUM	58U

/***************** Macros (Inline Functions) Definitions *********************/
/****************************************************************************/

/**************************** Type Definitions *******************************/

/** Wm8978 does not support iic read, all register values are stored in a local
 *	array.
 *	When writing register values to wm8978 through iic, the data in the array 
 *	should be updated with the same value simultaneously.
 *	When reading from wm8978, the related reading function should not read
 *	wm8978 through iic, just return the correspond data in the array mentioned
 *	above.
 *
 * 
 */

/*
static u16 wm8978_regval_table[58]=
{
	0X0000,0X0000,0X0000,0X0000,0X0050,0X0000,0X0140,0X0000,
	0X0000,0X0000,0X0000,0X00FF,0X00FF,0X0000,0X0100,0X00FF,
	0X00FF,0X0000,0X012C,0X002C,0X002C,0X002C,0X002C,0X0000,
	0X0032,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
	0X0038,0X000B,0X0032,0X0000,0X0008,0X000C,0X0093,0X00E9,
	0X0000,0X0000,0X0000,0X0000,0X0003,0X0010,0X0010,0X0100,
	0X0100,0X0002,0X0001,0X0001,0X0039,0X0039,0X0039,0X0039,
	0X0001,0X0001
};
*/

/**************************/
static u8 wm8978_regval_table[58<<1]=
{
	0X00,0x00,	//0
	0X00,0x00,
	0X00,0x00,
	0X00,0x00,
	0X00,0x50,
	0X00,0x00,
	0X01,0x40,
	0X00,0x00,
	0X00,0x00,
	0X00,0x00,
	0X00,0x00,	//10
	0X00,0xFF,
	0X00,0xFF,
	0X00,0x00,
	0X01,0x00,
	0X00,0xFF,
	0X00,0xFF,
	0X00,0x00,
	0X01,0x2C,
	0X00,0x2C,
	0X00,0x2C,	//20
	0X00,0x2C,
	0X00,0x2C,
	0X00,0x00,
	0X00,0x32,
	0X00,0x00,
	0X00,0x00,
	0X00,0x00,
	0X00,0x00,
	0X00,0x00,
	0X00,0x00,	//30
	0X00,0x00,
	0X00,0x38,
	0X00,0x0B,
	0X00,0x32,
	0X00,0x00,
	0X00,0x08,
	0X00,0x0C,
	0X00,0x93,
	0X00,0xE9,
	0X00,0x00,	//40
	0X00,0x00,
	0X00,0x00,
	0X00,0x00,
	0X00,0x03,
	0X00,0x10,
	0X00,0x10,
	0X01,0x00,
	0X01,0x00,
	0X00,0x02,
	0X00,0x01,	//50
	0X00,0x01,
	0X00,0x39,
	0X00,0x39,
	0X00,0x39,
	0X00,0x39,
	0X00,0x01,
	0X00,0x01	//57
}; 
/*********************************/

/**************************** Function Definitions *******************************/
s32 wm8978_write_bytes(u8 reg_addr, u8 *value, u8 bytecnt);

void wm8978_init();

void wm8978_write_callbackref();	//application level call back reference handler 
										//for driver level interrupt handler.

XIicPs_IntrHandler wm8978_intr_handler();



#ifdef __cplusplus
}
#endif


#endif

